﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Media;
using System.Xml;
using System.Xml.Linq;

using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.CommonBot.Frames;
using Styx.CommonBot.Profiles;
using Styx.Helpers;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;

using DefaultValue = Styx.Helpers.DefaultValueAttribute;

namespace BrodiesPlugin
{
    public partial class BrodiesPluginUI : Form
    {
        public int lastUseProfile = 0;
        public int numberBotBase;
        public string pathToCharSettings = Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Settings\Char" + StyxWoW.Me.Name + ".xml");
        public string pathToSettings = Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Settings\Main-Settings.xml");
        public string pathToProfiles = Path.Combine(Utilities.AssemblyDirectory + @"\Default Profiles\TBMC\");
        public string profileToLoad = "";
        bool isRunningdepois;
        bool BeenInitialized4;

        public BrodiesPluginUI()
        {
            InitializeComponent();
        }

        private void BrodiesPluginUI_Load(object sender, EventArgs e)
        {
			UpdateStuff(); // Load Saved Settings
			string Folder = "Plugins\\BrodiesPlugin\\Settings\\";
			string dailyFolder = "Default Profiles\\TBMC\\Reputation\\TMOPDE\\";
			string sPath = Process.GetCurrentProcess().MainModule.FileName;
			sPath = Path.GetDirectoryName(sPath);
			
			BPSettings.Instance.dailiesDirName = Path.Combine(sPath, dailyFolder);
			
			BPSettings.Instance.Profile1 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Golden Lotus Dailies [Brodie].xml");
			BPSettings.Instance.Profile2 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Tillers Dailies [Brodie].xml");
			BPSettings.Instance.Profile3 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Cloud Serpent Dailies [Brodie].xml");
			BPSettings.Instance.Profile4 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] The Anglers Dailies [Brodie].xml");
			BPSettings.Instance.Profile5 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Shieldwall [Brodie].xml");
			BPSettings.Instance.Profile6 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] The Klaxxi Dailies [Brodie].xml");
			BPSettings.Instance.Profile7 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Shado Pan Dailies [Brodie].xml");
			if (StyxWoW.Me.IsAlliance)
			{
				BPSettings.Instance.Profile8 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Isle of Thunder A [Brodie].xml");
				BPSettings.Instance.Profile9 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Isle of Thunder PvP A [Brodie].xml");
			}
			if (StyxWoW.Me.IsHorde)
			{
				BPSettings.Instance.Profile8 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Isle of Thunder H [Brodie].xml");
				BPSettings.Instance.Profile9 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Isle of Thunder PvP H [Brodie].xml");
			}
			BPSettings.Instance.Profile10 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] August Celestials Dailies [Brodie].xml");
			BPSettings.Instance.Profile11 = Path.Combine(BPSettings.Instance.dailiesDirName, "[Rep] Nat Pagle Dailies [TBMP].xml");
			// BPSettings.Instance.Profile12 = Path.Combine(BPSettings.Instance.dailiesDirName, "");
			
            // Init the Questing Tab
            radioButton1.Checked = false;
            radioButton2.Checked = false;
            radioButton3.Checked = false;
            radioButton20.Checked = false;
            // Init the Animus
            // Init the Grinding Tab
            radioButton21.Checked = false;
            radioButton22.Checked = false;
            radioButton23.Checked = false;
            radioButton24.Checked = false;
            radioButton4.Checked = false;
            radioButton5.Checked = false;
            radioButton6.Checked = false;
            radioButton7.Checked = false;
            radioButton11.Checked = false;
            radioButton10.Checked = false;
            radioButton9.Checked = false;
            radioButton8.Checked = false;
            radioButton19.Checked = false;
            radioButton18.Checked = false;
            radioButton17.Checked = false;
            radioButton16.Checked = false;
            radioButton15.Checked = false;
            radioButton14.Checked = false;
            radioButton13.Checked = false;
            radioButton12.Checked = false;
			// Init the Dailies checkBoxes
			checkBox1.Checked = BPSettings.Instance.Active1;
            RecolorBoxes(checkBox1);
			checkBox2.Checked = BPSettings.Instance.Active2;
            RecolorBoxes(checkBox2);
			checkBox3.Checked = BPSettings.Instance.Active3;
            RecolorBoxes(checkBox3);
			checkBox4.Checked = BPSettings.Instance.Active4;
            RecolorBoxes(checkBox4);
			checkBox5.Checked = BPSettings.Instance.Active5;
            RecolorBoxes(checkBox5);
			checkBox6.Checked = BPSettings.Instance.Active6;
            RecolorBoxes(checkBox6);
			checkBox7.Checked = BPSettings.Instance.Active7;
            RecolorBoxes(checkBox7);
			checkBox8.Checked = BPSettings.Instance.Active8;
            RecolorBoxes(checkBox8);
			checkBox9.Checked = BPSettings.Instance.Active9;
            RecolorBoxes(checkBox9);
			checkBox10.Checked = BPSettings.Instance.Active10;
            RecolorBoxes(checkBox10);
			checkBox11.Checked = BPSettings.Instance.Active11;
            RecolorBoxes(checkBox11);
			checkBox12.Checked = BPSettings.Instance.Active12;
            RecolorBoxes(checkBox12);
            checkBox13.Checked = BPSettings.Instance.Active13;
            RecolorBoxes(checkBox13);
			checkBox1.Enabled = false;
			checkBox2.Enabled = false;
			checkBox3.Enabled = false;
			checkBox4.Enabled = false;
			checkBox5.Enabled = false;
			checkBox6.Enabled = false;
			checkBox7.Enabled = false;
			checkBox8.Enabled = false;
			checkBox9.Enabled = false;
			checkBox10.Enabled = false;
			checkBox11.Enabled = false;
            checkBox12.Enabled = false; // ALWAYS, its reserved

            if (checkBox13.Checked == true)
            {
                checkBox1.Enabled = true;
				checkBox2.Enabled = true;
				checkBox3.Enabled = true;
				checkBox4.Enabled = true;
				checkBox5.Enabled = true;
				checkBox6.Enabled = true;
				checkBox7.Enabled = true;
				checkBox8.Enabled = true;
				checkBox9.Enabled = true;
				checkBox10.Enabled = true;
				checkBox11.Enabled = true;
                checkBox13.BackColor = System.Drawing.Color.Green;
            }
            else
                checkBox13.BackColor = System.Drawing.Color.Red;
			
			// Check for Alliance Shieldwall - Disable Dominance
			if (StyxWoW.Me.IsAlliance)
			{
				textBox5.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1376)); // Operation: Shieldwall
                textBox8.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1387)); // Kirin Tor Offensive
				textBox9.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1387)); // Kirin Tor Offensive
			}
			// Check for Horde Dominance - Disable Shieldwall
			if (StyxWoW.Me.IsHorde)
			{
				textBox5.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1375)); // Dominance Offensive
				textBox8.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1388)); // Sunreaver Onslaught
                textBox9.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1388)); // Sunreaver Onslaught
			}

			// Let's check Faction reps... why not make things easier? We are checking above too for Ally / Horde only.
			textBox1.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1269)); // Golden Lotus
			textBox2.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1272)); // The Tillers
			textBox3.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1271)); // Cloud Serpent
			textBox4.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1302)); // The Anglers
			textBox6.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1337)); // The Klaxxi
			textBox7.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1270)); // Shado Pan
			textBox10.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1341)); // August Celestials
			textBox11.Text = Convert.ToString(StyxWoW.Me.GetReputationLevelWith(1358)); // Nat Pagle
			textBox12.Text = "Reserved";
			
            this.checkBox1.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_faction_goldenlotus.jpg");
            this.checkBox2.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_faction_tillers.jpg");
            this.checkBox3.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_faction_serpentriders.jpg");
            this.checkBox4.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_faction_anglers.jpg");
            if (StyxWoW.Me.IsAlliance)
            {
                this.checkBox5.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\pvpcurrency-honor-alliance.jpg");
                this.checkBox8.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_reputation_kirintor_offensive.jpg");
                this.checkBox9.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_reputation_kirintor_offensive.jpg");
            }
            if (StyxWoW.Me.IsHorde)
            {
                this.checkBox5.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\pvpcurrency-honor-horde.jpg");
                this.checkBox8.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_faction_sunreaveronslaught.jpg");
                this.checkBox9.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_faction_sunreaveronslaught.jpg");
            }
            this.checkBox6.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_faction_klaxxi.jpg");
            this.checkBox7.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_faction_shadopan.jpg");
            this.checkBox10.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\achievement_faction_celestials.jpg");
            this.checkBox11.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\inv_helmet_50.jpg");
            this.checkBox12.Image = new Bitmap(Application.StartupPath + "\\Plugins\\BrodiesPlugin\\Images\\trade_engineering.jpg");

            pictureBox1.ImageLocation = Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\donate.png");
            pictureBox2.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\coollogo.png"));
            pictureBox3.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\coollogo.png"));
            pictureBox4.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\coollogo.png"));
            pictureBox5.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\coollogo.png"));
            pictureBox6.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\coollogo.png"));
            pictureBox7.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\coollogo.png"));
            tabPage8.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\MemoryLoaded.jpg"));
            tabPage9.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\MemoryLoaded.jpg"));
			tabPage10.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\MemoryLoaded.jpg"));
			tabPage11.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\MemoryLoaded.jpg"));
			tabPage12.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\MemoryLoaded.jpg"));
			tabPage13.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\MemoryLoaded.jpg"));
            tabPage14.BackgroundImage = new Bitmap(Path.Combine(Utilities.AssemblyDirectory + @"\Plugins\BrodiesPlugin\Images\The_Animus_Menu.jpg"));
            BeenInitialized4 = BrodiesPlugin.hasBeenInitialized4;
        }

        public void UpdateStuff()
        {
            BPSettings.Instance.Load();
            BPGlobalSettings.Instance.Load();
            lastUseProfile = BPSettings.Instance.lastUsedPath;
            if (BeenInitialized4 == false)
            {
                BPGlobalSettings.Instance.Save();
            }
		}

        public class BPSettings : Settings
        {
            public static readonly BPSettings Instance = new BPSettings();
            public BPSettings()
                : base(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"Plugins\BrodiesPlugin\Settings\Char-Settings-{0}-{1}.xml", StyxWoW.Me.RealmName, StyxWoW.Me.Name)))
            {
            }
            [Setting, DefaultValue(0)]
            public int lastUsedPath { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active1 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile1 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active2 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile2 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active3 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile3 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active4 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile4 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active5 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile5 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active6 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile6 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active7 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile7 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active8 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile8 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active9 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile9 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active10 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile10 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active11 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile11 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active12 { get; set; }
			[Setting, DefaultValue("")]
            public string Profile12 { get; set; }
			[Setting, DefaultValue(false)]
            public bool Active13 { get; set; }
			[Setting, DefaultValue("")]
            public string dailiesDirName { get; set; }
        }

        public class BPGlobalSettings : Settings
        {
            public static readonly BPGlobalSettings Instance = new BPGlobalSettings();
            public BPGlobalSettings()
                : base(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"Plugins\BrodiesPlugin\Settings\Main-Settings.xml")))
            {
            }
            [Setting, DefaultValue(false)]
            public bool AllowUpdate { get; set; }
            [Setting, DefaultValue(false)]
            public bool Allowlaunch { get; set; }
            [Setting, DefaultValue(0)]
            public int BaseProfileToLaunch { get; set; }
        }

        public void RecolorBoxes(CheckBox CB)
        {
            if (CB.Checked)
                CB.BackColor = System.Drawing.Color.Green;
            else
                CB.BackColor = System.Drawing.Color.Red;
        }

        private void pictureBox1_Click(object sender, EventArgs e) // Paypal
        {
            ProcessStartInfo sInfo = new ProcessStartInfo("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=davidl_rt06%40yahoo%2ecom&lc=US&item_name=TheBrodieMan%27s%20Dinner%20Fund&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted");
            Process.Start(sInfo);
        }

        private void checkBox13_CheckedChanged(object sender, EventArgs e) // Dailies Enabler
        {
            if (checkBox13.Checked == false) // If Dailies are off
            {
                checkBox1.Enabled = false;
                checkBox2.Enabled = false;
                checkBox3.Enabled = false;
                checkBox4.Enabled = false;
                checkBox5.Enabled = false;
                checkBox6.Enabled = false;
                checkBox7.Enabled = false;
                checkBox8.Enabled = false;
                checkBox9.Enabled = false;
                checkBox10.Enabled = false;
                checkBox11.Enabled = false;
                checkBox12.Enabled = false;
                lastUseProfile = 0;
            }
            else
            {
                checkBox1.Enabled = true;
                checkBox2.Enabled = true;
                checkBox3.Enabled = true;
                checkBox4.Enabled = true;
                checkBox5.Enabled = true;
                checkBox6.Enabled = true;
                checkBox7.Enabled = true;
                checkBox8.Enabled = true;
                checkBox9.Enabled = true;
                checkBox10.Enabled = true;
                checkBox11.Enabled = true;
                //checkBox12.Enabled = true; DISABLED
                lastUseProfile = 5; // Dailies
            }
            RecolorBoxes(checkBox13);
        }
		
		public void SaveProfileChoice()
		{
			BPSettings.Instance.Active1 = checkBox1.Checked;
			BPSettings.Instance.Active2 = checkBox2.Checked;
			BPSettings.Instance.Active3 = checkBox3.Checked;
			BPSettings.Instance.Active4 = checkBox4.Checked;
			BPSettings.Instance.Active5 = checkBox5.Checked;
			BPSettings.Instance.Active6 = checkBox6.Checked;
			BPSettings.Instance.Active7 = checkBox7.Checked;
			BPSettings.Instance.Active8 = checkBox8.Checked;
			BPSettings.Instance.Active9 = checkBox9.Checked;
			BPSettings.Instance.Active10 = checkBox10.Checked;
			BPSettings.Instance.Active11 = checkBox11.Checked;
			BPSettings.Instance.Active12 = checkBox12.Checked;
			BPSettings.Instance.Active13 = checkBox13.Checked;
		}

        private void button4_Click(object sender, EventArgs e) // Dailies Start Button
        {
            lastUseProfile = 5; // Dailies Run
            BPGlobalSettings.Instance.Save();
			SaveProfileChoice();
            BPSettings.Instance.Save();
            ProfileSelector();
        }

        private void button2_Click(object sender, EventArgs e) // Questing Start Button
        {
            checkBox13.Checked = false;
            BPGlobalSettings.Instance.Save();
			SaveProfileChoice();
            BPSettings.Instance.Save();
            ProfileSelector();
        }

        private void button3_Click(object sender, EventArgs e) // Grind It Start Button
        {
            checkBox13.Checked = false;
            BPGlobalSettings.Instance.Save();
			SaveProfileChoice();
            BPSettings.Instance.Save();
            ProfileSelector();
        }

        private void ProfileSelector()
        {
            if (lastUseProfile == null || lastUseProfile == 0)
                return;

            // Questing Profiles
            if (lastUseProfile == 1) { lancaprofile(pathToProfiles + "Questing\\[Quest] The Level Grind [Brodie].xml"); }
            if (lastUseProfile == 2) { lancaprofile(pathToProfiles + "Achievements\\Lost and Found\\[Ach] Lost and Found [Brodie].xml"); }
            if (lastUseProfile == 4) { lancaprofile(pathToProfiles + "Achievements\\Lorewalkers\\[Ach] Lorewalkers [Brodie].xml"); }
            // Battlefield Barrens Profiles
            if (lastUseProfile == 3) { lancaprofile(pathToProfiles + "Grinding\\Barrens\\Battlefield Barrens [Brodie].xml"); }
            if (lastUseProfile == 6) { lancaprofile(pathToProfiles + "Grinding\\Barrens\\Barrens Wood [Brodie].xml"); }
            if (lastUseProfile == 7) { lancaprofile(pathToProfiles + "Grinding\\Barrens\\Barrens Oil [Brodie].xml"); }
            if (lastUseProfile == 8) { lancaprofile(pathToProfiles + "Grinding\\Barrens\\Barrens Stone [Brodie].xml"); }
            if (lastUseProfile == 9) { lancaprofile(pathToProfiles + "Grinding\\Barrens\\Barrens Meat [Brodie].xml"); }
            // Dailies Profile(s)
            if (lastUseProfile == 5) { lancaprofile(pathToProfiles + "Reputation\\TMOPDE\\[Rep] Daily Grind [Brodie].xml"); }
            // Farm Grinds
            if (lastUseProfile == 10) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Enigma Seeds.xml"); }
            if (lastUseProfile == 11) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Green Cabbage Seeds.xml"); }
            if (lastUseProfile == 12) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Jade Squash Seeds.xml"); }
            if (lastUseProfile == 13) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Juicyfruit Carrot Seeds.xml"); }
            if (lastUseProfile == 14) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Magebulb Seeds.xml"); }
            if (lastUseProfile == 15) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Mogu Pumpkin Seeds.xml"); }
            if (lastUseProfile == 16) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Pink Turnip Seeds.xml"); }
            if (lastUseProfile == 17) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Raptorleaf Seeds.xml"); }
            if (lastUseProfile == 18) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Red Blossom Leeks Seeds.xml"); }
            if (lastUseProfile == 19) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Scallion Seeds.xml"); }
            if (lastUseProfile == 20) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Snakeroot Seeds.xml"); }
            if (lastUseProfile == 21) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Songbell Seeds.xml"); }
            if (lastUseProfile == 22) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Striped Melon Seeds.xml"); }
            if (lastUseProfile == 23) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\White Turnip Seeds.xml"); }
            if (lastUseProfile == 24) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Windshear Cactus Seeds.xml"); }
            if (lastUseProfile == 25) { lancaprofile(pathToProfiles + "Grinding\\Tillers Farm Planting Profiles\\Witchberry Seeds.xml"); }
            if (lastUseProfile == 26) { lancaprofile(pathToProfiles + "Grinding\\The Black Prince\\[Rep] The Black Prince - ZuTual [Brodie].xml"); }
            if (lastUseProfile == 27) { lancaprofile(pathToProfiles + "Grinding\\Isle of Giants\\[Rep] Isle of Giants Direhorns[Brodie].xml"); }
            if (lastUseProfile == 28) { lancaprofile(pathToProfiles + "Grinding\\Isle of Giants\\[Rep] Isle of Giants Dinomancers [Brodie].xml"); }
            // Animus Profiles
            if (lastUseProfile == 51) { lancaprofile(pathToProfiles + "The Animus\\EasternKingdomsMemBlock [Brodie].xml"); }
            if (lastUseProfile == 52) { lancaprofile(pathToProfiles + "The Animus\\KalimdorMemBlock [Brodie].xml"); }
        }

        private void lancaprofile(string ProfileToLoad)
        {
            bool isRunningantes = TreeRoot.IsRunning;
            if (isRunningantes)
            {
                BPGlobalSettings.Instance.Allowlaunch = true;
                BPGlobalSettings.Instance.BaseProfileToLaunch = lastUseProfile;
                BPGlobalSettings.Instance.Save();
                Close();
            }
            else
            {
                var questBot = BotManager.Instance.Bots.FirstOrDefault(kvp => kvp.Key == "Questing");
                if (questBot.Key == "Questing")
				{
					BotManager.Instance.SetCurrent(questBot.Value);
					Thread.Sleep(2000);
				}
				else
				{
					Logging.Write("Unable to locate Questing bot");
				}
			}
			Styx.CommonBot.Profiles.ProfileManager.LoadNew(ProfileToLoad);
			Close();
			Thread.Sleep(2000);
			TreeRoot.Start();
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 1; // Leveling 1 - 90
            richTextBox1.Text = "This profile will level-up any character from as low as level 1 up til level 90. \n Each race and faction combo has its own path. \n Profiles added and updated regularly.";
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 2; // Lost and Found Item Grind
            richTextBox1.Text = "This profile will fly around Pandaria, attempting to collect items for Lost and Found. \n This profile requires Pandaria Flying. \n Recommended you have a plugin or addon that automatically clicks the YES button for Bind on Pickup items.";
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 3; // Battlefield Barrens
            richTextBox1.Text = "This profile will conduct the weekly quest Battlefield: Barrens. \n Will gather 150 of each item before turning in. \n This profile requires you to already have the daily unlocked (prereqs done).\n YOU MUST BE IN KALIMDOR TO USE THIS.";
        }

        private void radioButton20_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 4; // Lorewalkers
            richTextBox1.Text = "This profile will fly to all the locations of scrolls for the Lorewalkers reputation quests. \n Requires Pandaria Flying.";
        }

        private void button1_Click(object sender, EventArgs e) // Main Page Close and Save Button
        {
			SaveProfileChoice();
            BPSettings.Instance.Save();
            BPGlobalSettings.Instance.Save();
            Close();
            isRunningdepois = TreeRoot.IsRunning;
            if (isRunningdepois) { TreeRoot.Stop(); }
        }

        private void button5_Click(object sender, EventArgs e) // Dailies Page Close and Save Button
        {
			SaveProfileChoice();
            BPSettings.Instance.Save();
            BPGlobalSettings.Instance.Save();
            Close();
            isRunningdepois = TreeRoot.IsRunning;
            if (isRunningdepois) { TreeRoot.Stop(); }
        }

        private void button6_Click(object sender, EventArgs e)
        {
			SaveProfileChoice();
            BPSettings.Instance.Save();
            BPGlobalSettings.Instance.Save();
            Close();
            isRunningdepois = TreeRoot.IsRunning;
            if (isRunningdepois) { TreeRoot.Stop(); }
        }

        private void button7_Click(object sender, EventArgs e)
        {
			SaveProfileChoice();
            BPSettings.Instance.Save();
            BPGlobalSettings.Instance.Save();
            Close();
            isRunningdepois = TreeRoot.IsRunning;
            if (isRunningdepois) { TreeRoot.Stop(); }
        }

        private void button8_Click(object sender, EventArgs e)
        {
			SaveProfileChoice();
            BPSettings.Instance.Save();
            BPGlobalSettings.Instance.Save();
            Close();
            isRunningdepois = TreeRoot.IsRunning;
            if (isRunningdepois) { TreeRoot.Stop(); }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.thebuddyforum.com/honorbuddy-forum/submitted-profiles/neutral/97995-rep-ach-thebrodiemans-profile-compendium.html");
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.thebuddyforum.com/honorbuddy-forum/submitted-profiles/neutral/85684-rep-complete-mop-daily-experience.html");
        }

        private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.thebuddyforum.com/honorbuddy-forum/submitted-profiles/117968-thebrodiemans-leveling-questing-do-er-grinder-thingy.html");
        }

        private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.thebuddyforum.com/honorbuddy-forum/submitted-profiles/neutral/94878-rep-lorewalkers.html");
        }

        private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.thebuddyforum.com/");
        }

        private void linkLabel6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.thebuddyforum.com/honorbuddy-forum/honorbuddy-guides/108771-help-desk.html");
        }

        private void linkLabel7_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.thebuddyforum.com/honorbuddy-forum/submitted-profiles/129137-animus-thebrodieman-productions-loremaster-project.html");
        }

        private void radioButton21_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 6; // Wood Run
            richTextBox3.Text = "This profile will grind items for the weekly quest Battlefield: Barrens. \n Will gather 500 wood before flying out and stopping. \n This profile requires you to already have the daily unlocked (prereqs done).";
        }

        private void radioButton22_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 7; // Oil Run
            richTextBox3.Text = "This profile will grind items for the weekly quest Battlefield: Barrens. \n Will gather 500 oil before flying out and stopping. \n This profile requires you to already have the daily unlocked (prereqs done).";
        }

        private void radioButton23_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 8; // Stone Run
            richTextBox3.Text = "This profile will grind items for the weekly quest Battlefield: Barrens. \n Will gather 500 stone before flying out and stopping. \n This profile requires you to already have the daily unlocked (prereqs done).";
        }

        private void radioButton24_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 9; // Meat Run
            richTextBox3.Text = "This profile will grind items for the weekly quest Battlefield: Barrens. \n Will gather 500 meat before flying out and stopping. \n This profile requires you to already have the daily unlocked (prereqs done).";
        }

        private void radioButton25_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 26; // Black Prince Rep
            richTextBox3.Text = "This profile will grind for Black Prince rep in the Isle of Thunder (Za'Tual Area). \n Must have done prereqs to zone, recommend starting within zone.";
        }

        private void radioButton26_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 27; // Dino Bones Grind Direhorns
            richTextBox3.Text = "This profile will grind for Dino Bones on the Isle of Giants by killing Direhorns. \n Your safety is not guaranteed. Avoidance is not perfect. Pathing is not perfect.";
        }

        private void radioButton27_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 28; // Dino Bones Grind Dinomancers
            richTextBox3.Text = "This profile will grind for Dino Bones on the Isle of Giants by killing Dinomancers. \n Your safety is not guaranteed. Avoidance is not perfect. Pathing is not perfect.";
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 10;
            richTextBox3.Text = "This profile will plant Enigma seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton5_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 11;
            richTextBox3.Text = "This profile will plant Green Cabbage seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton6_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 12;
            richTextBox3.Text = "This profile will plant Jade Squash seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton7_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 13;
            richTextBox3.Text = "This profile will plant Juicyfruit Carrot seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton8_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 14;
            richTextBox3.Text = "This profile will plant Magebulb seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton9_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 15;
            richTextBox3.Text = "This profile will plant Mogu Pumpkin seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton10_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 16;
            richTextBox3.Text = "This profile will plant Pink Turnip seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton11_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 17;
            richTextBox3.Text = "This profile will plant Raptorleaf seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton12_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 18;
            richTextBox3.Text = "This profile will plant Red Blossom Leek seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton13_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 19;
            richTextBox3.Text = "This profile will plant Scallion seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton14_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 20;
            richTextBox3.Text = "This profile will plant Snakeroot seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton15_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 21;
            richTextBox3.Text = "This profile will plant Songbell seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton16_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 22;
            richTextBox3.Text = "This profile will plant Striped Melon seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton17_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 23;
            richTextBox3.Text = "This profile will plant White Turnip seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton18_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 24;
            richTextBox3.Text = "This profile will plant Windshear Cactus seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void radioButton19_CheckedChanged(object sender, EventArgs e)
        {
            lastUseProfile = 25;
            richTextBox3.Text = "This profile will plant Witchberry seeds at the farm, and farm up any plants available. \n It will plant only as many spots as available. \n This profile requires you to have the farm unlocked (tillers prereqs done).";
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox1);
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox2);
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox3);
        }

        private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox4);
        }

        private void checkBox5_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox5);
        }

        private void checkBox6_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox6);
        }

        private void checkBox7_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox7);
        }

        private void checkBox8_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox8);
        }

        private void checkBox9_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox9);
        }

        private void checkBox10_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox10);
        }

        private void checkBox11_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox11);
        }

        private void checkBox12_CheckedChanged(object sender, EventArgs e)
        {
            RecolorBoxes(checkBox12);
        }

        private void label41_Click(object sender, EventArgs e) // Eastern Kingdoms Click to Start
        {
            lastUseProfile = 51; // Loremaster - Eastern Kingdoms
            BPGlobalSettings.Instance.Save();
            SaveProfileChoice();
            BPSettings.Instance.Save();
            ProfileSelector();
        }

        private void label42_Click(object sender, EventArgs e) // Kalimdor Click to Start
        {
            lastUseProfile = 52; // Loremaster - Kalimdor
            BPGlobalSettings.Instance.Save();
            SaveProfileChoice();
            BPSettings.Instance.Save();
            ProfileSelector();
        }
    }
}
